<!DOCTYPE html>
<html>
<head>
    <title>维护页面</title>
    <script type="text/javascript">
//        导入
$(function () {
    $("#importCustBtn").click(function () {
        $("#custUploadForm input[type=file]").click();
    });

    $("#custUploadForm input[name=file]").live("change", function () {
        $("#custUploadForm").ajaxSubmit({
            success: function (data) {
                importCustSuccess(data);
            }
        });
    });
});
function importCustSuccess(data) {
    var result = JSON.parse(data);
    if (result.returnCode == 1) {
        var url = "${absoluteContextPath}/td/tdMxb/importTd";
        var path = result.content;
        $.ajax({
            url: url,
            type: 'post',
            data: {path: path},
            success: function (msg) {
                refreshTable();
                msg = JSON.parse(msg);
                var pop_div = $('#errorMessage');
                var message = "";
                var texts = {};
                texts = msg.returnMsg.split("!");
                for (var r = 0; r < texts.length; r++) {
                    if (r < texts.length - 1) {
                        message += (texts[r] + "!<br>");
                    } else {
                        message += (texts[r]);
                    }
                }
                $("#info").html(message);
                pop_div.modal('show');
                $("input[name=file]").val(null);

            }
        });
    } else {
        $.showMessage({parentId: "showMessage", message: "<strong>错误信息</strong>：" + result.returnMsg, type: "error"});
    }
}
        function popAddOrModify(id) {
            var data = {};
            var url = '${absoluteContextPath}/td/tdMxb';
            if (id != undefined) {
                data.id = id;
                url = url + "/goEdit";
            } else {
                url = url + "/goAdd";
            }
            $.ajax({
                url:url,
                type:'post',
                data:data,
                success:function(data) {
                    var data = JSON.parse(data);
                    if (data.returnCode == 1) {
                        var pop_div = $('#myModal');
                        pop_div.html(data.content.data);
                        pop_div.modal('show');
                    } else {
                        $.showMessage({parentId:"showMessage",message:"数据加载异常！",type:"success"});
                    }
                }
            });
        }

        function deleteTdMxb() {
            var i = 0;
            $("input[name=ids]").each(function () {
                if ($(this).prop("checked")) {
                    i++;
                }
            });
            if(i == 0) {
                $.showMessage({parentId:"showMessage",message:"请选择您要删除的记录！",type:"success"});
                return false;
            } else {
                $.confirm({
                    confirm:function() {
                        var values = "";
                        $("input[name=ids]").each(function () {
                            if ($(this).prop("checked")) {
                                values += $(this).val() + ",";
                            }
                        });
                        $("#confirmModal").modal("hide");
                            $.post("${absoluteContextPath}/td/tdMxb/delete", {
                            'ids' : values
                        }, function(data) {
                            data = JSON.parse(data);
                            if (data.returnCode == 1) {
                                    $.showMessage({parentId:"showMessage",message:"数据删除成功！",type:"success"});
                                refreshTable();
                            } else {
                                    $.showMessage({parentId:"showMessage",message:"数据删除异常！",type:"error"});
                            }
                        });
                    }
                });
            }
        }

         function refreshTable() {
            $("input[name=currentPage]").val(1);
            $("#search_tdMxb_table").ajaxSubmit({
                url:'${absoluteContextPath}/td/tdMxb/ajaxList',
                success:function(data) {
                    var data = JSON.parse(data);
                    if (data.returnCode == 1) {
                        $("#tableContent").html(data.content.data);
                    } else {
                        $.showMessage({parentId:"showMessage",message:"表格数据加载异常！",type:"success"});
                    }
                }
            });
        }

        $(function () {
            $("input[name=entryDate]").focus(function () {
                WdatePicker({dateFmt: 'yyyy-MM-dd'});
            })
            $("input[name=entryEnd]").focus(function () {
                WdatePicker({dateFmt: 'yyyy-MM-dd'});
            })
            $("div[class='tooltip fade top in']").hide();
        });
        function doDownLoadTemplate() {
            $("#Form_Download").submit();
        }
    </script>
</head>
<body>

<div class="breadcrumbs">
    <ol class="breadcrumb">
        <li><a href="${absoluteContextPath}/home"><i class="fa fa-home"></i>首页</a></li>
        <li><a href="#">天道</a></li>
        <li class="active">1000小时明细表</li>
    </ol>
</div>

<div class="main">
    <!-- row -->
    <div class="row">
        <div class="col-md-12">
            <section class="tile">
                <!-- tile body -->
                <div class="tile-body">
                    <div id="showMessage"><#include "../../message.ftl" /></div>
                    <div class="form-horizontal">
                        <form id="search_tdMxb_table" action="${absoluteContextPath}/td/tdMxb/list" method="post">
                            <input type="hidden" name="pageSize" value="${tdMxbsTable.page.pageSize}"/>
                            <input type="hidden" name="currentPage" value="${tdMxbsTable.page.currentPage}"/>


                            <div class="row">

                                <div class="form-group col-md-4">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">姓名</label>
                                    <div class="col-sm-8">
                                        <input class="form-control" name="userName" value="${tdMxbParams.userName!''}" placeholder="" type="text">
                                    </div>
                                </div>
                                <div class="form-group col-md-4">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">录入日期</label>
                                    <div class="col-sm-8">
                                        <input class="form-control" name="entryDate" value="${(tdMxbParams.entryDate?string("yyyy-MM-dd"))!''}" placeholder="" type="text">
                                    </div>
                                </div>
                                <div class="form-group col-md-4">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">----</label>
                                    <div class="col-sm-8">
                                        <input class="form-control" name="entryEnd" value="${(tdMxbParams.entryEnd?string("yyyy-MM-dd"))!''}" placeholder="" type="text">
                                    </div>
                                </div>
                            </div>
                                <div class="row">
                                    <div class="form-group col-md-4">
                                        <label class="col-sm-4"></label>
                                        <div class="col-sm-8">
                                            <button type="button" class="btn btn-primary" onclick="refreshTable()">查询</button>
                                            <button type="reset" class="btn btn-default">重置</button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                    </div>
                </div>
            </section>
            <section class="tile">
                <div class="tile-header">
                    <h1>
                        <button type="button" class="btn btn-green" onclick="popAddOrModify();"><i class="fa fa-plus"></i><span class="margin-left-5">新增</span></button>
                        <button type="button" class="btn btn-cyan" onclick="deleteTdMxb();"><i class="fa fa-trash-o"></i><span  class="margin-left-5">删除</span></button>

                        <button id="importCustBtn" type="button" class="btn btn-cyan"><i
                                class="fa fa-arrow-circle-o-down"></i><span class="margin-left-5">导入模板</span>
                        </button>
 <button type="button" class="btn  btn-primary" onclick="doDownLoadTemplate();"><i
                                class="fa fa-download"></i><span class="margin-left-5">导入模板下载</span></button>

                    </h1>
                </div>
                <div class="tile-body nopadding">
                    <div class="table-responsive" id="tableContent">
                        <#include "table.ftl"/>
                    </div>
                </div>
            </section>
        </div>
    </div>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    </div>
    <form id="Form_Download" action="${absoluteContextPath}/td/tdMxb/downloadTemplate" method="post"
          style="display: none">
        <input name="serverFileName" type="hidden" value="TdDownload.xlsx"/>
        <!-- 下载潜在客户导入模板 -->
        <input name="clientFileName" type="hidden" value="1000小时自我管理.xlsx"/>
        <!-- 下载潜在客户导入模板 -->
    </form>
    <form id="custUploadForm" method="post" enctype="multipart/form-data"
          action="${absoluteContextPath}/upload/ajax" style="display: none">
        <input type="file" name="file"/>
        <input type="text" name="fileType" value="xlsx">
    </form>
    <div class="modal fade" id="errorMessage" tabindex="-1" role="dialog" aria-labelledby="cardCode04"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">导入提示</h4>
                </div>
                <div class="modal-body">
                    <div id="info"></div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
    </div>



</div>
</body>
</html>
